package sort;

public class InsertionSort {

	public static int[] sort(int[] arr){

		//int length = arr.length;

		for(int j = 1; j < arr.length; j++){
			int key = arr[j];

			int i = 0;
			while(i < j){
				if(arr[i] > key){
					int k = j;
					while(k > i){
						arr[k] = arr[k-1];
						k--;						
					}
					arr[k] = key;
					break;
				}
				i++;
			}

		}

		return arr;

	} 
}
